package com.yuan.controller;

import com.yuan.pojo.Student;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

//@Controller
//@ResponseBody
@RestController
@RequestMapping("/hello")
public class HelloController {


    @GetMapping("/doRequestParameter")
    public String doRequestParameter(@RequestParam(value = "stuName") String stuName,@RequestParam(value = "stuAge")  Integer stuAge) {
        System.out.println("stuName = " + stuName);
        System.out.println("stuAge = " + stuAge);
        return "success";
    }

    @GetMapping("/test")
    public String test() {
        return "success";
    }



    @PostMapping("/testPojoParam")
    public String testPojoParam(Student student){
        System.out.println("student = " + student);
        return "success";
    }

    @PostMapping("/testJSONParam")
    public String testJSONParam(@RequestBody  Student student /*String jsonStr*/){
        //        System.out.println("jsonStr = " + jsonStr);    //json字符串
        System.out.println("student = " + student);
        return "success";
    }


    @GetMapping("/testCookieInfo")
    public String testCookieInfo(@CookieValue("JSESSIONID") String jsessionId){
        System.out.println("jsessionId = " + jsessionId);
        return "success";
    }
    @ResponseBody
    @GetMapping("/testRequestHeaderInfo")
    public String testRequestHeaderInfo(@RequestHeader("User-Agent") String userAgent){
        System.out.println("User-Agent = " + userAgent);
        return "success";
    }



}
